﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

using System.Collections.Generic;

public partial class TVMedia3Web_Reportes_ReporteOperacionesTipoServicio : System.Web.UI.Page
{
    
    private ReportData reportData = null;
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            DateTime year = DateTime.Now;

            DateTime yearFinal = year.AddYears(5);
            DateTime yearInicial = year.AddYears(-5);
            DropDownListTextFiller.FillDropDownList(ddlDiaInicio, DropDownListTextFiller.NullTextValue, 1, 31);
            DropDownListTextFiller.FillDropDownList(ddlMesInicio, DropDownListTextFiller.NullTextValue, 1, 12);
            DropDownListTextFiller.FillDropDownList(ddlAnhoInicio, DropDownListTextFiller.NullTextValue, yearInicial.Year, yearFinal.Year);

            DropDownListTextFiller.FillDropDownList(ddlDiaFin, DropDownListTextFiller.NullTextValue, 1, 31);
            DropDownListTextFiller.FillDropDownList(ddlMesFin, DropDownListTextFiller.NullTextValue, 1, 31);
            DropDownListTextFiller.FillDropDownList(ddlAnhoFin, DropDownListTextFiller.NullTextValue, yearInicial.Year, yearFinal.Year);
        }
        Session.Clear();
    }

    protected void AddNullValue(object sender, EventArgs e)
    {
        DropDownList list = (DropDownList)sender;

        list.Items.Insert(0, DropDownListTextFiller.NullTextValue);
    }
    protected void btnConsultar_Click(object sender, EventArgs e)
    {
        Session.Clear();

        FilterDataBinder filterDataBinder = new FilterDataBinder();
        
        filterDataBinder.AddFilterData("id_tipo_atencion", ddlTipoTicket,WhereFilter.WhereOperation.Equal,WhereFilter.SQLValueType.Integer);
        filterDataBinder.AddFilterData("Fecha",  new DropDownList[]{ddlDiaInicio,ddlMesInicio, ddlAnhoInicio},WhereFilter.WhereOperation.MoreEqualThan,WhereFilter.SQLValueType.String);
        filterDataBinder.AddFilterData("Fecha", new DropDownList[]{ddlDiaFin,ddlMesFin, ddlAnhoFin},WhereFilter.WhereOperation.LessEqualThan,WhereFilter.SQLValueType.String);
        
        filterDataBinder.BindData();
       
        SelectSentenceBuilder selectb = new SelectSentenceBuilder("vw_ReporteOperacionTipoServicio");
        selectb.Filters = filterDataBinder.Filters;
        selectb.Build();
        string select = selectb.GetBuiltSelect();
       
        reportData = new ReportData();
        reportData.ReportPath = MapPath(@"ArchivosReportes/ReporteOperacionTipoServicio.rpt");
        reportData.ReportSelect = select;
        reportData.TableName = "vw_ReporteOperacionTipoServicio";
       
        Session[ReportData.SessionReportDataKey] = reportData;
        Session["Titulo"] = "Reporte de operaciones por tipo de servicio";
        Response.Redirect(@"~\Reportes\Common\VisualizadorReportes.aspx");

    }
   
   
}
